#include <signal.h>
#include <stdio.h>
#include <stdlib.h>

void sigcb_2(int sig)
{
    printf("block failed , number 2 has been delivered..\n");
    exit(-1);
}

void sigcb_40(int sig)
{
    printf("block failed , number 40 has been delivered..\n");
    exit(-1);
}

int main()
{
    //把2、40号信号添加到待加入位图
    sigset_t set;
    sigaddset(&set,2);
    sigaddset(&set,40);

    //捕捉2号信号和40号信号
    signal(2,sigcb_2);
    signal(40,sigcb_40);

    //每两秒给自己发送一次2号信号和40号信号
    int cnt = 6;
    while(--cnt)
    {
        printf("number 2 and 40 have been sent... it %d time\n",6-cnt);
        sleep(2);
    }

    printf("block success..\n");
    return 0;
}